<?php 
	session_start();
	include('include/db_connect.php');
	include('include/header.php');
	include('include/menu.php');
	
	if(!isset($_GET['id']) || $_GET['id'] == "") {
		echo "Product niet gevonden. U wordt terugverwezen naar een vorige pagina.";
		header("Location: productoverzicht.php?sub1=&sub2=");
	}
	
	$productQuery = mysql_query("SELECT * ".
	                            "FROM PRODUCT ".
	                            "WHERE `idPRODUCT` = ".$_GET['id']);
	if(!$productQuery) {
		die("Query failed. Please try again later.<br>".mysql_error());
	} else {
		$productResult = mysql_fetch_assoc($productQuery);
	}
	$prijs = $productResult['prijs'] * (1 - ($productResult['korting']) / 100);
	echo "<div id='main_content'>";
	echo "<div id='super_main_content'>";
	echo "<div id='product_img'><div id ='back_button'><input type='button' value='Ga terug naar de vorige pagina.' onClick='history.go(-1)'></div>";
	echo "<img src='images/producten/normal/normal_".$productResult['bestandsnaam']."'></div><br>";
	echo "<h2>".$productResult['naam']."</h2><br>";
	echo "Omschrijving: <br>".wordwrap($productResult['omschrijving'], 50, "<br>")."<br><br>";
	if($productResult['korting'] != 0) {
		echo "<h6>Oorspronkelijke prijs: &euro; ".$productResult['prijs']."</h6>";
		echo "Huidige prijs: &euro; ".number_format($prijs, 2);
	} else {
		echo "Prijs: &euro; ".$prijs;
	}
	echo "<br>";
	echo "<a href='winkelwagen.php?id=".$_GET['id']."&action=add'>Bestel!</a>";
	
	echo "</div>";
	echo "</div>";	
	echo "<div class='clearthis'></div>";
	include('include/footer.php');
?>